<?php 
if (! defined('BASEPATH')) {
	exit('Access Denied');
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>网站参数设置</title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url();?>/static/css/admin/base.css">
<script src="<?php echo base_url();?>/static/js/jquery.js" language="javascript"></script>


<script type="text/javascript">
$(function(){

	$("#make_data").click(function(){
		var url ="<?php echo site_url('admin/web_manager/index/make_data') ;?>";
		$.ajax({
			   type: "POST",
			   url: url ,
			   data: "",
			   cache:false,
			   dataType:"json",
			 //  async:false,
			   success: function(msg){
				var code = msg.resultcode ;
				if(code <0){
					$("#p_result").show().html('<font color="red">对不起权限不足。。。</font>');
					return false ;
				}  
				
			//	result = msg.resultinfo.list.result ;
				
				$("#p_result").show().html('<font color="green">'+msg.resultinfo.errmsg+'</font>');
				
			   },
			   beforeSend:function(){
				  $("#p_result").show().html('<font color="red">正在生成请稍候。。。</font>');
			   },
			   error:function(){
				   alert("服务器繁忙");
			   }
			  
			});	
});
	
$(".form2").hide();	
$(".form2").eq(0).show();	

$(".nav_des a").removeClass("nav_des_hover");
$(".nav_des a").eq(0).addClass("nav_des_hover");
});



function show_hide_div(id,o){
	$(".form2").hide();
	$("#newform_"+id).show();
	$("#add_").hide();
	//添加class
	$(".nav_des a").removeClass("nav_des_hover");
	o.className = "nav_des_hover";
}

function del(url){
	if(confirm('是否确定删除')){
		window.location.href = url ;
	}else{
		return false ;
	}
	
}
</script>
</head>
<body leftmargin="8" topmargin="8">
<div class="nav_des">
<span class="des">系统核心设置>></span>
<?php 
	if($group_){
		for($g = 1 ;$g<=count($group_); $g++){	
?>
<a href="javascript:void(0)" onclick="show_hide_div(<?php echo $g; ?>,this)" ><?php echo $group_[$g];?></a>
<?php 
	}
}	
?>
<a href="javascript:void(0)" class="" onclick="show_hide_div(<?php echo count($group_)+1;?>,this)">添加新变量</a>
</div>



<?php 
	if($group_){
		for($g_key = 1 ;$g_key<=count($group_); $g_key++){
	
?>

<form class="form2" method="post"  action="<?php echo site_url("admin/web_manager/index/site_config");?>" id="newform_<?php echo $g_key ;?>"   style="">
<input type="hidden" name="action" value="add_config">
<input type="hidden" name="operation" value="edit_varname">
<table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" align="center" style="margin-top:8px" id="table_">
<tr bgcolor="#E7E7E7">
	<td height="24" colspan="10" >&nbsp;<?php echo $group_[$g_key];?> 配置&nbsp;</td>
</tr>
<tr align="" bgcolor="#FAFAF1" height="22">
	<td width="14%">参数说明</td>
	<td width="">参数值</td>
	<td width="13%">变量名</td>
	<td width="5%">操作</td>
</tr>

<?php 
	if(isset($list_[$g_key])){
		foreach($list_[$g_key] as $mykey=>$myval){
	
?>
<tr align="" bgcolor="#FAFAF1" height="30">
	<td width="14%"><?php echo $myval['info'];?>:</td>
	<td width=""><?php echo $myval['in_'];?></td>
	<td width="13%"><?php echo $myval['varname'];?></td>
	<td width="5%"><a href="javascript:void(0)" onclick="return del('<?php echo site_url("admin/web_manager/index/del");?>?varname=<?php echo $myval['varname']; ?>')"><img src='<?php echo base_url();?>/static/image/admin/gtk-del.png'></a></td>
</tr>

<?php 
	}	
}
?>
<tr align="" bgcolor="#FAFAF1" height="27">
	<td width="19%" colspan="4" align="center">
		<input type="submit" name="" value="修&nbsp;改" style="width:100px;display:block; height:23px">
	</td>
	
</tr>
</table>

</form>


<?php 
	}
}	
?>

<form method="post"  action="<?php echo site_url("admin/web_manager/index/site_config");?>"   style="">
<input type="hidden" name="action" value="add_config">
<table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" align="center" style="margin-top:8px ;display:none" id="newform_<?php echo count($group_)+1 ;?>" class="form2">

<tr align="" bgcolor="#FAFAF1" height="27">
<td>变量名称:(必须是英文)<input type="text" style="width:300px;height:21px" name="varname"></td>
<td>变量值:<input type="text" style="width:300px;height:21px" name="value"></td>
</tr>
<tr align="" bgcolor="#FAFAF1" height="27">
<td>变量类型:<input type="radio" name="type" value="string" checked>文本<input type="radio" name="type" value="number" >数字<input type="radio" name="type" value="boolean" >布尔(Y/N)<input type="radio" name="type" value="textarea" >多行文本</td>
<td>所属组:
<select name="group" style="width:300px">
<?php 
	if($group_){
		foreach($group_ as $group_key=>$group_val){
	
?>
<option value="<?php echo $group_key ;?>"><?php echo $group_val ; ?></option>
<?php 
	}
}	
?>
</select>

</td>
</tr>
<tr align="" bgcolor="#FAFAF1" height="28">
<td>参数说明:<input type="text" style="width:300px;height:21px" name="info"></td>
<td><input type="submit" name="" value="添加变量" style="height:24px ;margin-top:2px" ></td>
</tr>
</table>
</form>

<div style="width:100% ; background:#E7E7E7 ;margin:auto ;margin-top:40px ; text-align:center ; height:35px ;  padding:9px ;line-height:20px;">
	<input type="button" value="生成数据文件" style="height:24px ;margin-top:2px;cursor:pointer" id="make_data">
</div>
<div style="width:100% ; background:#E7E7E7 ;margin:auto ;margin-top:10px ; text-align:center ; height:30px ; line-height:30px ; display:none" id="p_result">
	
</div>



</body>
</html>
